
<!doctype html>

<html>

<head>
  <meta http-equiv="Content-type" content="text/html; charset=utf08" />
  <title>Basis Source Viewer</title>

  <link rel="stylesheet" type="text/css" title="Default Style" href="../style/highlight/style.css" media="screen" />

  <script type="text/javascript" basis-config="{}" src="../src/basis.js"></script>

  <style type="text/css">
    BODY
    {
      color: black;
      font-size: small;
    }
    .selected
    {
      background: gold !important;
    }
  </style>
</head>

<body>
  <script type="text/javascript">
    basis.require('basis.format.highlight');
    basis.require('basis.net.ajax');

    var line = parseInt((location.hash || '').replace(/^#/, ''));
    var filename = ((location.search || '').match(/[\?\&]file=([^&]+)/) || [])[1];
    if (filename)
    {
      var transport = new basis.net.ajax.Transport({
        url: '../' + filename,
        handler: {
          complete: function(sender, req){
            //t = new Date;
            var node = new basis.format.highlight.SourceCodeNode({
              container: document.body,
              lang: 'js',
              normalize: false,
              data: {
                code: req.data.responseText//.replace(/^\s*\n/, function(m){ return '.' + m })
              }
            });

            //alert(new Date - t)
            if (!isNaN(line))
            {
              var lineElement = node.element.childNodes[line - 1];
              if (lineElement)
              {
                lineElement.className += ' selected';
                setTimeout(function(){
                  document.documentElement.scrollTop =
                  document.body.scrollTop = lineElement.offsetTop - 200;
                }, 15);
              }
            }
          }
        }
      });
      transport.get();
    }
  </script>
</body>

</html>